package com.sm.auth.vo;

import com.sm.auth.entity.UmsSysUser;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;
@Data
public class LoginUserVo implements UserDetails {
    private Long id;
    private String token;
    private UmsSysUser umsSysUser;
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return List.of();
    }

    @Override
    public String getPassword() {
        return umsSysUser.getPassword();
    }

    @Override
    public String getUsername() {
        return umsSysUser.getUsername();
    }

    @Override
    public boolean isAccountNonExpired() {
        return umsSysUser.getStatus() == 0;//0 可用  1 不可用
    }

    @Override
    public boolean isAccountNonLocked() {
        return umsSysUser.getStatus() == 0;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return umsSysUser.getStatus() == 0;
    }

    @Override
    public boolean isEnabled() {
        return umsSysUser.getStatus() == 0;
    }
}
